package com.vshop.controller.alast.subscribe;

import com.vshop.config.dto.ResultDataDto;
import com.vshop.entity.alast.single.subscribe.sub.request.RequestMailSubscribe;
import com.vshop.entity.alast.single.subscribe.sub.response.ResponseMailSubscribe;
import com.vshop.entity.alast.single.subscribe.subornot.request.RequestMailSubscribedOrNot;
import com.vshop.entity.alast.single.subscribe.subornot.response.ResponseMailSubscribedOrNot;
import com.vshop.service.alast.LogicProcessesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;

/**
 * 接口1：当前设备用户是否已经邮箱订阅？没有展示订阅框框
 * 接口2：邮件订阅
 *
 * @author lm
 * @date 2020/7/29 13:51
 */
@RestController
@Api(value = "邮件订阅")

public class MailSubscribeController implements Serializable {

    @Autowired
    LogicProcessesService subscribeService;

    @CrossOrigin
    @PostMapping(value = "mailSubscribedOrNot", produces = "application/json;charset=utf-8")
    @ResponseBody
    @ApiOperation(value = "是否已经邮箱订阅?", response = ResponseMailSubscribedOrNot.class)
    public ResultDataDto mailSubscribedOrNot(@ApiParam @RequestBody RequestMailSubscribedOrNot request) {
        return subscribeService.mailSubscribedOrNot(request);
    }


    @CrossOrigin
    @PostMapping(value = "mailSubscribe", produces = "application/json;charset=utf-8")
    @ResponseBody
    @ApiOperation(value = "邮件订阅：1-订阅；2-异常信息提交", response = ResponseMailSubscribe.class)
    public ResultDataDto mailSubscribe(@ApiParam @RequestBody RequestMailSubscribe request) {
        return subscribeService.mailSubscribe(request);
    }

}
